<?php

namespace App\Http\Requests\Strator;

use Illuminate\Foundation\Http\FormRequest;

class StoreStratorPositionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'department_id'=>'required|integer|min:0',
            'position_name'=>'required|string|min:1|max:30',
            'position_code'=>'sometimes|alpha_num|max:20|unique:strator_positions,position_code',
            // 'position_remark'=>'sometimes|string|max:200',
            'sort'=>'required|integer',
        ];
    }
    /**
     * Get the error messages for the defined validation rules.
     *
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'department_id.required' => '部门id参数为必传',
            'department_id.integer' => '部门id参数不正确',
            'department_id.min' => '部门id参数不正确',

            'position_name.required' => '职务角色名称为必填',
            'position_name.string' => '职务角色名称只能是字符串类型',
            'position_name.min' => '职务角色名称长度要在1-30位之间',
            'position_name.max' => '职务角色名称长度要在1-30位之间',

            'position_code.alpha_num' => '职务角色代码只能是字母或者数字',
            'position_code.max' => '职务角色代码长度要在0-20位之间',
            'position_code.unique' => '职务角色代码已存在',

            // 'position_remark.string' => '职务角色名称只能是字符串类型',
            // 'position_remark.max' => '职务角色简介长度要在0-200个字符之间',

            'sort.integer' => '排序值只能是整数',

        ];
    }
}
